<?php 
include '../functions.php';

try{
    $dsn="mysql:host=127.0.0.1;dbname=zuoye";
	$pdo = new Pdo($dsn,"root","");
	//设置字符集
	$pdo->query("set names utf8");
	//错误属性
	$pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
	//开始准备，返回对象
	$state = $pdo->prepare("update student set username=? where sid=?");
	$username = "张";
	$sid = 4;
	//绑定参数
	$state->bindParam(1,$username,PDO::PARAM_STR);
	$state->bindParam(2,$sid,PDO::PARAM_INT);
	//执行，返回受影响的条数
	$rows = $state->execute();
	p($rows);
    
}catch(PDOException $e){
      //die($e->getMessage());
	  echo $e->getMessage();
}


















